package
{
	import flash.display.Sprite;
	import com.greensock.*;
	import com.greensock.loading.*;
	import com.greensock.events.LoaderEvent;
	import com.greensock.loading.display.*;	
	[SWF(width="790", height="570", frameRate="30",wmode="direct")]
	public class preload extends Sprite
	{
		public function preload()
		{
			//create a LoaderMax named "mainQueue" and set up onProgress, onComplete and onError listeners
			var queue:LoaderMax = new LoaderMax({name:"mainQueue", onProgress:progressHandler, onComplete:completeHandler, onError:errorHandler});
			
			//append several loaders
			queue.append( new SWFLoader("mytest.swf", {name:"mainClip", estimatedBytes:3000, container:this}) );
			queue.append( new SWFLoader("sounds.swf", {name:"sound"}) );
			queue.append( new XMLLoader("data.xml", {name:"dataXML", alternateURL:"http://otherserver.com/data.xml"}) );
			//queue.append( new ImageLoader("img/photo1.jpg", {name:"photo1", estimatedBytes:2400, container:this, alpha:0, width:250, height:150, scaleMode:"proportionalInside"}) );
			
			//add a loader to the top of the queue using prepend()
			//queue.prepend( new MP3Loader("mp3/audio.mp3", {name:"audio", repeat:100, autoPlay:true}) );
			
			//prioritize the loader named "photo1"
			//LoaderMax.prioritize("photo1");  //same as LoaderMax.getLoader("photo1").prioritize();
			
			//start loading
			queue.load();
		}

		
		private function progressHandler(event:LoaderEvent):void {
			trace("progress: " + event.target.progress);
		}
		
		private function completeHandler(event:LoaderEvent):void {
			//var image:ContentDisplay = LoaderMax.getContent("photo1");
			//TweenLite.to(image, 1, {alpha:1, y:100});
			trace(event.target + " is complete!");
			var image:ContentDisplay = LoaderMax.getContent("mainClip");
			image.rawContent.login();
			
		}
		
		private function errorHandler(event:LoaderEvent):void {
			trace("error occured with " + event.target + ": " + event.text);
		}		
	}
}